﻿<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"  %>
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>图书借阅管理系统</title>
	<link rel="stylesheet" type="text/css" href="../../plugins/jquery-easyui/themes/metro/easyui.css">
	<link rel="stylesheet" type="text/css" href="../../plugins/jquery-easyui/themes/icon.css">
	<link rel="stylesheet" type="text/css" href="../../css/index/index.css">
	<script type="text/javascript" src="../../plugins/jquery-easyui/jquery.min.js"></script>
	<script type="text/javascript" src="../../plugins/jquery-easyui/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="../../plugins/jquery-easyui/locale/easyui-lang-zh_CN.js"></script>
	<script type="text/javascript" src="../../js/index/treeData.js"></script>
	<style type="text/css">
		#header{
			position: relative;
		}	
		#userCenter, #loginOut{
			position: absolute;
			right: 0px;
			bottom: 0px;
		}
		#userCenter{
			right: 65px;
		}
	</style>
</head>

<body class="easyui-layout" >
	<!-- 页眉 -->
	<div id="header" data-options="region:'north'" >
		<h2>图书借阅管理系统</h2>
		<a id="userCenter" href="#" onclick="openTab('个人信息修改', 'userCenter')" class="easyui-linkbutton" data-options="iconCls:'icon-ex-user'">个人中心</a>
		<a id="loginOut" href="javaScript:loginOut();" class="easyui-linkbutton" data-options="iconCls:'icon-ex-logout'">注销</a>
	</div>
	
	<!-- 内容 -->
	<div data-options="region:'center'">
		<div class="easyui-tabs" data-options="fit:'true',border:'false'"  id="tabs">
			<div title="首页">
			</div>
		</div>
	</div>
	<div id="container" data-options="region:'west'" title="功能菜单">
		<div id="accordion" class="easyui-accordion" data-options="fit:'true'" >
			<div title="图书管理" data-options="iconCls:'icon-ex-report',select:'false'" >
				<ul id="tree_bookManager" class="easyui-tree"></ul>
			</div>
			<c:if test="${sessionScope.authority != 0}">
				<div title="借阅管理" data-options="iconCls:'icon-ex-borrowbookManage'">
					<ul id="tree_borrowManager" class="easyui-tree"></ul>
				</div>
				<div title="读者管理" data-options="iconCls:'icon-ex-userManage'">
					<ul id="tree_readerManager" class="easyui-tree"></ul>
				</div>
				<div title="报表分析" data-options="iconCls:'icon-ex-table'">
					<ul id="tree_reportAnalysis" class="easyui-tree"></ul>
				</div>
			</c:if>
			<c:if test="${sessionScope.authority == -1}">
				<div title="系统管理" data-options="iconCls:'icon-ex-systemManage'">
					<ul id="tree_systemManager" class="easyui-tree"></ul>
				</div>
			</c:if>
		</div>
	</div>

	<!-- 页脚 -->
	<div id="footer" data-options="region:'south'">
		CopyRight&copy;<a href="#">Buffermaker</a>
	</div>
	
	<script type="text/javascript">
	// 新增Tab
	function openTab(text, url){
		if ($('#tabs').tabs('exists', text)){
			$('#tabs').tabs('select', text);
		} else {
			var content = "<iframe frameborder='0' scrolling='auto' style='width:100%;height:100%;margin-bottom:-4px;' src=" + url + "></iframe>";
			$('#tabs').tabs('add', {
				title: text,
				closable: true,
				content: content
			});
		}
	}
	
	function loginOut(){
		sessionStorage.removeItem("user");
		sessionStorage.removeItem("authority");
		window.location.href = "loginOut";
	}
	
	$(function (){
		// 实例化树控件
		$('#tree_bookManager').tree({
			data: treeData_booksManage,
			lines: true,
			onClick: function(node){
				if (node.attributes){
					openTab(node.text, node.attributes.url);
				}
			}
		});

		$('#tree_borrowManager').tree({
			data: treeData_borrowManage,
			lines: true,
			onClick: function(node){
				if (node.attributes){
					openTab(node.text, node.attributes.url);
				}
			}
		});
		
		$('#tree_readerManager').tree({
			data: treeData_readerManage,
			lines: true,
			onClick: function(node){
				if (node.attributes){
					openTab(node.text, node.attributes.url);
				}
			}
		});
		
		$('#tree_reportAnalysis').tree({
			data: treeData_reportAnalysis,
			lines: true,
			onClick: function(node){
				if (node.attributes){
					openTab(node.text, node.attributes.url);
				}
			}
		});

		$('#tree_systemManager').tree({
			data: treeData_systemManage,
			lines: true,
			onClick: function(node){
				if (node.attributes){
					openTab(node.text, node.attributes.url);
				}
			}
		});

	});
</script>
</body>
</html>
